﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace XNA_3DFramWork
{
    public abstract class GameObject : DrawableGameComponent
    {
        public readonly BasicEffect BEffect;
        public Matrix Matrix;

        protected GameObject(Game game)
            : base(game)
        {
            BEffect = new BasicEffect(Game.GraphicsDevice, null);
        }

        public abstract void Draw();
        public abstract void Update();

        public void Move(float x, float y, float z)
        {
            Matrix Mat = Matrix.CreateTranslation(x, y, z);
            Matrix = Matrix.Multiply(Mat, Matrix);
        }

        public void RotateX(float x)
        {
            Matrix = Matrix.Multiply(Matrix.CreateRotationX(3*x), Matrix);
        }

        public void RotateY(float y)
        {
            Matrix = Matrix.Multiply(Matrix.CreateRotationY(3*y), Matrix);
        }

        public void RotateZ(float z)
        {
            Matrix = Matrix.Multiply(Matrix.CreateRotationZ(3*z), Matrix);
        }

        public void Scale(float x, float y, float z)
        {
            Matrix = Matrix.Multiply(Matrix.CreateScale(x, y, z), Matrix);
        }
    }
}